unit ASetUser;

interface

uses
  AModelBrowser, AData, APubUnit,
  Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
  Dialogs, ActnList, ComCtrls, ToolWin, DB, DBAccess,
  frxClass, frxDesgn, Menus, dxSkinsCore, dxSkinsDefaultPainters,
  cxControls, cxContainer, cxEdit, cxTextEdit, cxDBEdit, cxGraphics,
  cxCustomData, cxStyles, cxTL, ExtCtrls, cxSplitter, cxInplaceContainer,
  cxTLData, cxDBTL, Grids, Wwdbigrd, Wwdbgrid, StdCtrls, MemDS, MyAccess,
  cxGroupBox, TFlatButtonUnit, Mask, DBCtrls, cxMaskEdit, cxDropDownEdit;

type
  TASetUserForm = class(TAModelBrowserFrame)
    wwDBGrid1: TwwDBGrid;
    Qsys_users: TMyQuery;
    Dsys_users: TMyDataSource;
    cxSplitter1: TcxSplitter;
    Panel1: TPanel;
    GRPsys_users: TcxGroupBox;
    FlatButton1: TFlatButton;
    Qsys_usersdepart_no: TStringField;
    Qsys_usersuser_id: TStringField;
    Qsys_usersuser_name: TStringField;
    Qsys_usersuser_pws: TStringField;
    Qsys_usersroles: TIntegerField;
    Qsys_userslimit: TIntegerField;
    Qsys_userscreate_name: TStringField;
    Qsys_userscreate_date: TDateTimeField;
    Qsys_usersupd_name: TStringField;
    Qsys_usersupd_date: TDateTimeField;
    user_id: TLabel;
    user_name: TLabel;
    gusers_name: TLabel;
    depart_no: TLabel;
    create_name: TLabel;
    create_date: TLabel;
    upd_name: TLabel;
    upd_date: TLabel;
    cxDBuser_id: TcxDBTextEdit;
    cxdbuser_name: TcxDBTextEdit;
    cxDBupd_date: TcxDBTextEdit;
    cxDBupd_name: TcxDBTextEdit;
    cxDBcreate_name: TcxDBTextEdit;
    cxDBcreate_date: TcxDBTextEdit;
    cmbGroupUser: TcxComboBox;
    procedure Qsys_usersAfterInsert(DataSet: TDataSet);
    procedure cmbGroupUserPropertiesCloseUp(Sender: TObject);
    procedure Qsys_usersAfterScroll(DataSet: TDataSet);
  private
    procedure FillCxComboBox;
  public
    procedure OpenDataSet; override;
  end;

var
  ASetUserForm: TASetUserForm;

implementation

{$R *.dfm}

{ TASetUserForm }

procedure TASetUserForm.FillCxComboBox;
begin
 QAPubDataOpen('select concat(gusers_no,''-'',gusers_name) as no_name from sys_groupusers order by 1');
 with  ADMSystem.QAPubData do
 begin
 First;
 while not ADMSystem.QAPubData.Eof do
 begin
   cmbGroupUser.Properties.Items.Add(Fields[0].Value);
   Next;
 end;
 end;
 cmbGroupUser.ItemIndex := -1;
end;

procedure TASetUserForm.OpenDataSet;
begin
  inherited;
  FillCxComboBox;
end;

procedure TASetUserForm.Qsys_usersAfterInsert(DataSet: TDataSet);
begin
  inherited;
  Qsys_usersuser_id.AsInteger  := GetMaxInteger('select max(user_id) user_id from sys_users');
end;

procedure TASetUserForm.cmbGroupUserPropertiesCloseUp(Sender: TObject);
var aStr: string;
begin
  inherited;
  aStr := cmbGroupUser.Text;
  if aStr = '' then Exit;
  aStr := Copy(aStr,1,Pos('-',aStr)-1);
 // ShowMessage(aStr);
end;

procedure TASetUserForm.Qsys_usersAfterScroll(DataSet: TDataSet);
begin
  inherited;
  //cmbGroupUser.Text :=
end;

initialization
  RegisterClass(TASetUserForm);
finalization
  UnRegisterClass(TASetUserForm);

end.

